<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>支付宝支付</title>
    <link rel="stylesheet" href="css/style.css" />
	<script type="text/javascript" src="jquery.min.js"></script>
	<script type="text/javascript" src="encrypt.js"></script>
    <style>
    	body{
    		background:#3ec1ff;
    	}
    	
    </style>
</head>
<body>
	<div class="wrapper">
		<div class="box">
			<div class="ercode">
				<div id="code"></div>
				<p>
                    <span class="tim">2016-07-29 9:52</span>
                    <br/>消费<span class="fee">100</span>元
                    <br/><span id="subject"></span>
                </p>
			</div>
            <img src="image/zhifubao.png"/>
			<div class="intro">确认去支付宝扫一扫支付</div>
		</div>
        <div class="bottom" style="color:#00aaef;"><img src="image/zhifubao.png"/>支付宝支付</div>
	</div>
</body>
<script>
var param = getUrl();
if(param.partnerCode != null && param.secret != null && param.memberNo != null ){
	if(param.transAmt != null && param.subject != null && param.bizcode != null){
		$(".fee").html(param.transAmt/100);
		$("#subject").html(param.subject);
		var content = {
			"subject" : param.subject,
			"bizcode" : param.bizcode,
			"memberNo" : param.memberNo,
			"transAmt" : param.transAmt,
			"orderNo" : "AL2001548856",
			"notifyUrl" : ""
		};
		content = JSON.stringify(content);
		console.info(content);
		$.ajax({
	        type: "POST",
	        url: "MemberTransaction",
	        dataType: 'json', 
	        data: encrypt(param.partnerCode, param.secret, content),
	        success: function(data) {
	        	if(data.respCode=="00"){
	        		var qrcode = new QRCode(document.getElementById("code"), { width : 200,  height : 200 });
	                qrcode.makeCode(data.codeUrl);
	        		var connection = new WebSocket('ws://open.qrcodexx.com:8001/unifypay/TransactionWebsocket/'+data.tranxSN);
	        		connection.onmessage=function(event){
	        			console.info(event.data);
	        			connection.close();
	        			if(JSON.parse(event.data).respCode == "00"){
		        			window.location.href="alipay2.html";
	        			} else {
	        				alert(JSON.parse(event.data).respDesc)
	        			}
	        		}
	        	}else{
	        		alert(data.respDesc);
	        	}
	        }
	    });
	}else{
		alert("未知的交易金额及描述！");
	}
}else{
	alert("未知的组织机构号！");
}
</script>
</html>